<template>
  <div>
      <table style="margin:0 auto;" border="1">
          <tr>
              <td>{{item.title}}</td>
              <td>{{item.content}}</td>
              <td>{{item.total_comment}}</td>
              <td>{{item.total_views}}</td>
          </tr>
      </table>
      <p v-for='i in comments'>
          {{i.content}}
      </p>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data(){
        return{
            item:{},
            comments:[],
            news_id:this.$route.query.news_id,
        }
    },
    created(){
        // console.log(this.news_id)
        this.get_news()
    },
    methods:{
        get_news(){
            axios.get('http://127.0.0.1:8000/myapp/get_news/',{
                params:{id:this.news_id}
            }).then(res=>{
                console.log(res.data)
                if(res.data.code==200){
                    this.item = res.data.news,
                    this.comments = res.data.comments
                }
            })
        }
    }
}
</script>

<style>

</style>